package com.fubowen.reader.book

interface IBook {
    /**
     * 是否获取到目录
     */
    var isGetCatalogState: Boolean

    /**
     * 所有的章节列表
     */
    val chapterList: MutableList<BookChapterBean>

    /**
     * 书籍的显示名称
     */
    var name: String

    /**
     * 书籍的来源地址
     */
    var url: String

    /**
     * 解析过程的错误
     */
    var errMsg: String?

    /**
     * 解析过程的进度
     */
    var onProgressChanged: (BookChapterBean) -> Unit

    /**
     * 解析完成的回调
     */
    var onCompleted: IBook.() -> Unit

    fun tryGet()
    fun tryGetCatalog()
    fun tryGetName()
    fun tryGetUrl()
}

interface OnProgressChanged {
    fun change(bookChapterBean: BookChapterBean)
}


data class BookChapterBean(
    var id: Int = 0,
    var name: String = "",
    var order: Int = 0,
    var content: String = "",
    var timestamp: Long = System.currentTimeMillis(),
    var bookId: Int = 0,
    var isReading: Boolean = false,
    var position: Int = 0,
    var words: Int = 0,
    var url: String? = null,
    var isDownload: Boolean = false
)